<docs>
## 已邀约页面
</docs>
<template>
  <div class="con-layout invited noPadBottom">
    <!-- <my-bread title="已邀约" :goback="true" ref="head"></my-bread> -->
    <div class="header">
      <span class="arrow" @click="back_btn"></span>
      <h3 class="title">已邀约</h3>
    </div>
    <div class="content">
      <list-bar ref="listBar" class="useListBar">
        <div
          class="list-bar-item"
          v-for="(item,index) in listBar"
          :key="index"
          :class="curIndex == index? 'active' :''"
          @click="triggerBar(item)"
        >
          <span>
            {{item.name}}
            <i v-if="item.dot">{{item.dot}}</i>
          </span>
        </div>
      </list-bar>
      <div class="sub-content">
        <!-- 职位 -->
        <div class="resume-con" ref="resumeCon">
          <van-list v-model="loading" :finished="finished" finished-text="没有更多了" @load="onLoad(typeIndex)">
            <div
              class="resume-item"
              v-for="(item,index) in list"
              :key="index"
              @click="goLink(item)"
            >
              <div class="resume-delivery">
                <span>
                  投递给“
                  <b>{{item.gwmc}}</b>”的简历
                </span>
              </div>
              <div class="resume-person clearfix">
                <span class="name">{{item.jlmc}}</span>
                <span class="link">点击查看</span>
                <p class="date">面试时间：{{item.msrq}}</p>
              </div>
            </div>
          </van-list>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import listBar from "base/listBar/listBar";

export default {
  components: { listBar },
  data() {
    return {
      list: [],
      loading: false,
      finished: false,
      pageNum: 1,
      pageSize: 10,
      listBar: [
        { name: "邀约中", resid: "yyz", index: 10 },
        { name: "面试通过", resid: "mstg", index: 20 },
        { name: "面试未通过", resid: "mswtg", index: 30 },
        { name: "未参加面试", resid: "wcjms", index: 40 }
      ],
      curIndex: 0,
      typeIndex: 10
    };
  },
  watch:{
    $route:{
      handler:function (val) {
        this.curIndex = val.query.type;
        this.typeIndex = (this.curIndex-0 + 1)*10;
      },
      immediate:true
    }
  },
  methods: {
    triggerBar(item) {
      this.curIndex = item.index / 10 - 1;
      this.$router.push({query: {type:this.curIndex}});
      this.list = [];
      this.pageNum = 1;
      this.onLoad(item.index);
    },
    onLoad(tdzt) {
      this.$http({
        url: "/msgl/yyyck",
        method: "get",
        params: {
          tdzt: tdzt || 10,
          pageNum: this.pageNum,
          pageSize: this.pageSize
        }
      }).then(res => {
        this.loading = false;
        this.finished = false;
        let _res = res.returnData;
        if (+_res.executeResult == 1) {
          this.pageNum++;
          this.list.push(..._res.gwxxCx);
          if (this.pageNum > res.pageCount) {
            // 数据加载完毕
            this.finished = true;
          }
        } else {
          this.finished = true;
        }
      });
    },
    goLink(item) {
      this.$loading = true;
      this.$http({
        url: "/dwgl/jlckBc",
        method: "post",
        data: {
          dwdjid: item.dwdjid,
          jlid: item.jlid,
          jlly: item.ckjllx,
          tdjlid: item.tdjlid,
          ckjlid: item.ckjlid
        }
      }).finally(()=>{
        this.$loading = false;
      }).then(res => {
        let _res = res.returnData;
        if (+_res.executeResult == 1) {
          this.$router.push({
            path: "/resume/resumeDetail",
            query: {
              jlid: item.jlid,
              tdjlid: item.tdjlid,
              jlly: item.ckjllx
            }
          });
        } else {
          this.alert({
            message: _res.message
          });
        }
      });
    },
    //返回已招聘
    back_btn(){
      this.$router.push({path:'/resume'});
    }
  }
};
</script>

<style lang="scss" scoped>
@import "~common/scss/var.scss";
.useListBar {
  position: fixed;
  top: $height-input;
  left: 0;
  z-index: 10;
  width: 100%;
}
.sub-content {
  padding: 100px 33px 33px;
}
.resume-con {
  overflow: visible;
}
</style>
